const express = require('express');
const router = express.Router();

// 实体类
const Response = require('../entity/http/Response');

// 业务层
const sysService = require('../service/sysService');

/**
 * @接口名称 获取轮播图接口
 */
router.get('/banners', async function(req, res, next) {
    console.log(`[log] [req-id=${req.reqId}] 进入了 /banners 接口`);
    sysService.getBanners().then((result) => {
        console.log(`[log] [req-id=${req.reqId}] 响应 result`, result);
        res.status(result.code).json(result);
    }).catch((err) => {
        console.log(`[log] [req-id=${req.reqId}] 服务器错误`, err);
        res.status(500).json((new Response()).fail(500, "资源不可访问"));
    });
});

module.exports = router;
